/**
 * @description 热门商店和商品信息操作
 * @author 李哲
 */

const Shop = require('../model/Shop');
const Product = require('../model/Product');

/**
 * 获取热门店铺
 * @returns 
 */
const getShopList = async () => {
    const newShop = await Shop.find();
    return newShop
}
/**
 * 获取单个店铺
 * @param {String} id 店铺id 
 */
const getShop = async (id) => {
    const newShop = await Shop.findById(id);
    return newShop
}

/**
 * 获取商品信息
 * @param {String} id 店铺id
 * @param {String} tab tab筛选栏条件
 * @returns 
 */
const getProductList = async (id, tab) => {
    const newProduct = await Product.find({
        shopId: id,
        tabs: {
            $in: tab
        }
    })
    return newProduct
}
module.exports = { getShopList, getShop, getProductList }